import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MatBomVO, MatBomForm, MatBomQuery } from '@/api/wmscloud/matBom/types';

/**
 * 查询物料BOM列表
 * @param query
 * @returns {*}
 */

export const listMatBom = (query?: MatBomQuery): AxiosPromise<MatBomVO[]> => {
  return request({
    url: '/wmsCloud/matBom/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料BOM详细
 * @param bomId
 */
export const getMatBom = (bomId: string | number): AxiosPromise<MatBomVO> => {
  return request({
    url: '/wmsCloud/matBom/' + bomId,
    method: 'get'
  });
};

/**
 * 新增物料BOM
 * @param data
 */
export const addMatBom = (data: MatBomForm) => {
  return request({
    url: '/wmsCloud/matBom',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料BOM
 * @param data
 */
export const updateMatBom = (data: MatBomForm) => {
  return request({
    url: '/wmsCloud/matBom',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料BOM
 * @param bomId
 */
export const delMatBom = (bomId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/matBom/' + bomId,
    method: 'delete'
  });
};
